home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / dbreak_c.zip / D_BREAK.ASM < prev    next >
Assembly Source File  |  1991-02-08  |  5KB  |  157 lines

  1. ; ===========================================================================
  2. ;    d_break.asm
  3. ; ---------------------------------------------------------------------------
  4. ;    Copyright (C) 1989.  Daniel J. Reynolds.  All Rights Reserved.
  5. ;    High Aspect Development Corporation.
  6. ;    45 Shore Drive # 909.
  7. ;    Ogden Dunes, IN. 46368  (219) 762-4725
  8. ; ---------------------------------------------------------------------------
  9. ;    $Log:   Z:/source/video/vcs/d_break.asv  $
  10. ;  
  11. ;     Rev 3.2   28 Jan 1991 14:09:00   DJR
  12. ;  Release3.Version2
  13. ;  
  14. ;     Rev 3.1   17 Jan 1991 05:08:26   DJR
  15. ;  Release3.Version1
  16. ;  
  17. ;     Rev 3.0   05 Sep 1990 00:00:58   DJR
  18. ;  Release3.Version0
  19. ; ===========================================================================
  20.  
  21. include   model.inc
  22.  
  23. param     struc
  24.  
  25. saved_bp  dw     ?
  26. ifdef     FAR_CALLS
  27. ret_addr  dd     ?
  28. else
  29. ret_addr  dw     ?
  30. endif
  31. ifdef     FAR_DATA
  32. cad_flg_addr   dd   ?
  33. else
  34. cad_flg_addr   dw   ?
  35. endif
  36.  
  37. param     ends
  38.  
  39. TEXT_SEG  VIDEO
  40. FUNCTION  break_off
  41. ;----------------------------------------------------------------------------
  42.           push   ds                    ;save registers
  43.           push   di
  44.           push   si
  45.  
  46.           mov    ax,word ptr [bp].cad_flg_addr ;Get the ctrl-alt-del flag 
  47.           mov    word ptr cs:flag,ax   ; offset and save it
  48. ifdef     FAR_DATA                     ;Get the ctrl-alt-del flag segment
  49.           mov    ax,word ptr [bp].cad_flg_addr+2 ; based on wether this is
  50. else                                   ; a far or near data memory model
  51.           mov    ax,ds
  52. endif
  53.           mov    word ptr cs:flag+2,ax ; and save it
  54.  
  55.                                        ;pick up original vector contents
  56.           mov    ax,3509h              ;for interrupt 09H (MS-DOS
  57.           int    21h                   ;Keyboard handler)
  58.           mov    word ptr cs:int09,bx
  59.           mov    word ptr cs:int09+2,es
  60.  
  61.           push   cs                    ;set address of new handler
  62.           pop    ds
  63.           mov    dx,offset kb_int
  64.           mov    ax,02509H
  65.           int    21h
  66.  
  67.           pop    si
  68.           pop    di
  69.           pop    ds                    ;restore registers and
  70. END_FUNC  break_off
  71. ;------------------------------------------------------------------------------
  72. FUNCTION  break_on
  73.           push   ds                    ;save registers
  74.           push   di
  75.           push   si
  76.  
  77.           lds    dx,cs:int09           ;set interrupt 1BH (MS-DOS Keyboard
  78.           mov    ax,2509h              ;interrupt handler)
  79.           int    21h
  80.  
  81.           pop    si
  82.           pop    di
  83.           pop    ds                    ;restore registers and
  84. END_FUNC  break_on
  85. ;------------------------------------------------------------------------------
  86. kb_int    PROC   far
  87.  
  88.           sti
  89.           push   ax                    ;save affected registers
  90.           push   bx
  91.           pushf
  92.           push   ds
  93.           push   es
  94.  
  95.           xor    ax,ax
  96.           mov    es,ax
  97.           mov    al,byte ptr es:[0417h]
  98.           and    al,0fh
  99.           cmp    al,0ch
  100.           jz     ck_delete
  101.       cmp    al,04h
  102.           jz     ck_break
  103.           jmp    short do_old
  104. ck_break:
  105.           in     al,60h
  106.           jmp    $+2
  107.           cmp    al,46h
  108.           jz     do_delete
  109.           cmp    al,2eh
  110.           jz     do_delete
  111.           jmp    short do_old
  112. ck_delete:
  113.           in     al,60h
  114.           jmp    $+2
  115.           cmp    al,53h
  116.           jz     do_delete
  117.           jmp    short do_old
  118. do_delete:
  119.           lds    bx,cs:flag            ;set flag within C program to "TRUE"
  120.           mov    word ptr ds:[bx],1
  121.           in     al,61h
  122.           jmp    $+2
  123.           mov    ah,al
  124.           or     al,80h
  125.           out    61h,al
  126.           jmp    $+2
  127.           xchg   ah,al
  128.           out    61h,al
  129.           jmp    $+2
  130.           mov    al,20h
  131.           out    20h,al
  132.           pop    es
  133.           pop    ds
  134.           popf
  135.           pop    bx
  136.           pop    ax
  137.           iret
  138. do_old:
  139.           pop    es                    ;restore registers and exit
  140.           pop    ds
  141.           popf
  142.           pop    bx
  143.           pop    ax
  144.           pushf
  145.           call   dword ptr cs:[int09]
  146.           iret
  147.  
  148. kb_int    endp
  149.  
  150. flag      dd     0                     ;long address of C program's
  151.                                        ;Control-Alt-Delete detected flag
  152. int09     dd     0                     ;original contents of MS-DOS
  153.                                        ;Keyboard Interrupt 09H
  154.                                        ;vector
  155. END_TEXT  VIDEO
  156.           end
  157.